<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveSupport::Callbacks::CallbackChain</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveSupport::Callbacks::CallbackChain</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/activesupport/lib/active_support/callbacks_rb.html">
                vendor/rails/activesupport/lib/active_support/callbacks.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Array
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000363">build</a>&nbsp;&nbsp;
      <a href="#M000367">delete</a>&nbsp;&nbsp;
      <a href="#M000366">find</a>&nbsp;&nbsp;
      <a href="#M000365">replace_or_append!</a>&nbsp;&nbsp;
      <a href="#M000364">run</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000363" class="method-detail">
        <a name="M000363"></a>

        <div class="method-heading">
          <a href="#M000363" class="method-signature">
          <span class="method-name">build</span><span class="method-args">(kind, *methods, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000363-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000363-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/callbacks.rb, line 80</span>
80:       <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">kind</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">methods</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
81:         <span class="ruby-identifier">methods</span>, <span class="ruby-identifier">options</span> = <span class="ruby-identifier">extract_options</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">methods</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
82:         <span class="ruby-identifier">methods</span>.<span class="ruby-identifier">map!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span> <span class="ruby-constant">Callback</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">kind</span>, <span class="ruby-identifier">method</span>, <span class="ruby-identifier">options</span>) }
83:         <span class="ruby-identifier">new</span>(<span class="ruby-identifier">methods</span>)
84:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000367" class="method-detail">
        <a name="M000367"></a>

        <div class="method-heading">
          <a href="#M000367" class="method-signature">
          <span class="method-name">delete</span><span class="method-args">(callback)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000367-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000367-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/callbacks.rb, line 113</span>
113:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">callback</span>)
114:         <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">callback</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Callback</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">callback</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">find</span>(<span class="ruby-identifier">callback</span>))
115:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000366" class="method-detail">
        <a name="M000366"></a>

        <div class="method-heading">
          <a href="#M000366" class="method-signature">
          <span class="method-name">find</span><span class="method-args">(callback) {|c| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000366-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000366-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/callbacks.rb, line 109</span>
109:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find</span>(<span class="ruby-identifier">callback</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
110:         <span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">callback</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-operator">!</span><span class="ruby-identifier">block_given?</span> <span class="ruby-operator">||</span> <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">c</span>)) }.<span class="ruby-identifier">first</span>
111:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000365" class="method-detail">
        <a name="M000365"></a>

        <div class="method-heading">
          <a href="#M000365" class="method-signature">
          <span class="method-name">replace_or_append!</span><span class="method-args">(chain)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
TODO: Decompose into more Array like behavior
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000365-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000365-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/callbacks.rb, line 100</span>
100:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">replace_or_append!</span>(<span class="ruby-identifier">chain</span>)
101:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">index</span> = <span class="ruby-identifier">index</span>(<span class="ruby-identifier">chain</span>)
102:           <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">index</span>] = <span class="ruby-identifier">chain</span>
103:         <span class="ruby-keyword kw">else</span>
104:           <span class="ruby-keyword kw">self</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">chain</span>
105:         <span class="ruby-keyword kw">end</span>
106:         <span class="ruby-keyword kw">self</span>
107:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000364" class="method-detail">
        <a name="M000364"></a>

        <div class="method-heading">
          <a href="#M000364" class="method-signature">
          <span class="method-name">run</span><span class="method-args">(object, options = {}, &amp;terminator)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000364-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000364-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/callbacks.rb, line 86</span>
86:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">terminator</span>)
87:         <span class="ruby-identifier">enumerator</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:enumerator</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:each</span>
88: 
89:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block_given?</span>
90:           <span class="ruby-identifier">send</span>(<span class="ruby-identifier">enumerator</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">callback</span><span class="ruby-operator">|</span> <span class="ruby-identifier">callback</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">object</span>) }
91:         <span class="ruby-keyword kw">else</span>
92:           <span class="ruby-identifier">send</span>(<span class="ruby-identifier">enumerator</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">callback</span><span class="ruby-operator">|</span>
93:             <span class="ruby-identifier">result</span> = <span class="ruby-identifier">callback</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">object</span>)
94:             <span class="ruby-keyword kw">break</span> <span class="ruby-identifier">result</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">terminator</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">result</span>, <span class="ruby-identifier">object</span>)
95:           <span class="ruby-keyword kw">end</span>
96:         <span class="ruby-keyword kw">end</span>
97:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>